home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / text / misc / pcal_4_5.lha / pcal / pcaldefs.h < prev    next >
C/C++ Source or Header  |  1994-10-16  |  24KB  |  800 lines

  1. /*
  2.  * pcaldefs.h - definitions for Pcal program
  3.  *
  4.  * Revision history:
  5.  *
  6.  *    4.5    AWR    08/24/94    Define CHAR_MSK (instead of hard-coded
  7.  *                    0377) to avoid negative result when
  8.  *                    promoting char to int (see comments)
  9.  *
  10.  *            12/21/93    Removed obsolete COLOR_MIN, COLOR_MAX
  11.  *                    definitions
  12.  *
  13.  *            11/08/93    Add IS_EURDATE() macro to support
  14.  *                    "nn." style of date specifications
  15.  *
  16.  *            09/09/93    Support Roman8 and ISO Latin1
  17.  *                    character mappings (cf. fontmaps.ps,
  18.  *                    writefil.c)
  19.  *
  20.  *                    Redefine MIN_YR from 1900 to 1753
  21.  *
  22.  *            03/20/93    Allow several site-specific program
  23.  *                    defaults to be set in Makefile
  24.  *
  25.  *            03/05/93    add MAPFONTS for optional mapping to
  26.  *                    8-bit fonts (for European languages)
  27.  *
  28.  *            12/29/92    add PS_RELEASE to define PostScript
  29.  *                    version (for Encapsulated PostScript)
  30.  *
  31.  *            04/07/92    Revise PUTCHAR macro: add <ctype.h>
  32.  *                    function/macro name and file pointer
  33.  *                    as arguments
  34.  *
  35.  *            02/11/92    Many new declarations to help support
  36.  *                    predefined holidays
  37.  *
  38.  *    4.4    AWR    02/10/92    Add PAGER_ENV (environment variable
  39.  *                    used in piping "help" message output
  40.  *                    [Un*x only])
  41.  *
  42.  *            01/20/92    Added support for -z flag and revised
  43.  *                    versions of -[bgGO]
  44.  *
  45.  *            01/13/92    Add default font size to DATEFONT and
  46.  *                    TITLEFONT; move initialization of all
  47.  *                    font sizes here (from pcalinit.ps);
  48.  *                    enlarge medium calendar font sizes
  49.  *
  50.  *    4.3    AWR    12/05/91    Revise moonfile name templates for
  51.  *                    consistency with current standards
  52.  *                    for substituting year in strings
  53.  *
  54.  *            12/03/91    Add support for -s flag
  55.  *
  56.  *            10/17/91    Add support for -Z flag and subflags;
  57.  *                    removed obsolete PUTSTR macro
  58.  *
  59.  *    4.2    AWR    10/08/91    Add support for -[kK] flags; renamed
  60.  *                    START_DAY as START_BOX for clarity
  61.  *
  62.  *            10/03/91    Add various definitions relating to
  63.  *                    "note/<n>"
  64.  *
  65.  *            09/30/91    Add MAX_IF_NESTING (related to "elif";
  66.  *                    cf. read_datefile() in readfile.c)
  67.  *
  68.  *    4.11    AWR    08/20/91    Add "nearest" keyword (as per Andy
  69.  *                    Fyfe)
  70.  *
  71.  *    4.1    AWR    08/16/91    Add support for -G flag
  72.  *
  73.  *    4.0    AWR    03/01/91    Add STDLIB macro for systems which
  74.  *                    support <stdlib.h>
  75.  *
  76.  *            02/22/91    add definitions for MS-DOS support (as
  77.  *                    per Floyd Miller)
  78.  *
  79.  *            02/19/91    revise ORD_XXX to support negative
  80.  *                    ordinals
  81.  *
  82.  *                    add definitions for Amiga support (as
  83.  *                    per Bill Hogsett)
  84.  *
  85.  *            02/06/91    additional defs for expression
  86.  *                    processing
  87.  *
  88.  *            02/04/91    support "year" as additional month
  89.  *                    name; use negative numbers for
  90.  *                    special ordinal codes (reserve
  91.  *                    positive numbers for ordinals)
  92.  *
  93.  *            01/28/91    miscellaneous new constants/macros
  94.  *
  95.  *            01/07/91    add FEB_29_OK (cf. enter_day_info())
  96.  *
  97.  */
  98.  
  99. /*
  100.  * System dependencies:
  101.  */
  102.  
  103. #ifdef VMS        /* VMS oddities isolated here */
  104.  
  105. #include <ssdef.h>    /* required for trnlog() */
  106. #include <descrip.h>
  107.  
  108. #define HOME_DIR    "SYS$LOGIN"
  109. #define DATEFILE    "calendar.dat"
  110. #define MOONFILE    "moon%y.dat"    /* '%y' replaced with year */
  111. #define DEFAULT_OUTFILE    "calendar.ps"
  112. #define START_PATH    '['
  113. #define END_PATH    ']'
  114.  
  115. #define EXIT_SUCCESS    1        /* VMS exit() parameters */
  116. #define EXIT_FAILURE    3
  117.  
  118. #else
  119. #ifdef AMIGA        /* more oddities for Amiga */
  120.  
  121. #include <string.h>
  122.  
  123. #define PROTOS                /* compiler accepts prototypes */
  124. #define STDLIB                /* system has <stdlib.h> */
  125. #define HOME_DIR    "RAM:"
  126. #define DATEFILE    "s:calendar.dat"
  127. #define MOONFILE    "s:.moon%y"    /* '%y' replaced with year */
  128. #define DEFAULT_OUTFILE    "RAM:calendar.ps"
  129. #define START_PATH    '/'
  130. #define END_PATH    '/'
  131.  
  132. #else
  133. #ifdef DOS        /* even more oddities for MS-DOS */
  134.  
  135. #define DATEFILE    "pcal.dat"
  136. #define MOONFILE    "moon%y.dat"    /* '%y' replaced with year */
  137. #define START_PATH    '\\'
  138. #define END_PATH    '\\'
  139. #define HOME_DIR    "HOME"
  140. #define ALT_DATEFILE    "calendar"    /* for backward compatibility */
  141.  
  142. #else            /* neither VMS, Amiga, nor MS-DOS - assume Un*x */
  143.  
  144. #define UN_X        /* to distinguish Un*x from others */
  145.  
  146. #define HOME_DIR    "HOME"
  147. #define DATEFILE    ".calendar"
  148. #define ALT_DATEFILE    "calendar"    /* for backward compatibility */
  149. #define MOONFILE    ".moon%y"    /* '%y' replaced with year */
  150. #define ALT_MOONFILE    "moon%y"    /* analogous to ALT_DATEFILE */
  151. #define START_PATH    '/'
  152. #define END_PATH    '/'
  153.  
  154. #define PAGER_ENV    "PAGER"        /* points to help message pager */
  155. #define PAGER_DEFAULT    "more"        /* default pager (NULL = none) */
  156.  
  157. #include <pwd.h>            /* password info (cf. writefil.c) */
  158.  
  159. #endif
  160. #endif
  161. #endif
  162.  
  163. /* define OUTFILE to DEFAULT_OUTFILE if defined, otherwise to "" (stdout) */
  164.  
  165. #ifdef DEFAULT_OUTFILE
  166. #define OUTFILE        DEFAULT_OUTFILE
  167. #else
  168. #define OUTFILE        ""
  169. #endif
  170.  
  171. /* PROTOS may be defined independently of __STDC__ for compilers which
  172.  * support function prototypes but are not fully ANSI-compliant
  173.  */
  174.  
  175. #if defined(__STDC__) && ! defined(PROTOS)
  176. #define PROTOS    
  177. #endif
  178.  
  179. /* STDLIB may be defined independently of __STDC__ for systems which
  180.  * support <stdlib.h> but are not fully ANSI-compliant
  181.  */
  182.  
  183. #if defined(__STDC__) && ! defined(STDLIB)
  184. #define STDLIB            /* cf. {no}protos.h */
  185. #endif
  186.  
  187. #ifdef STDLIB            /* include <stdlib.h> if known to exist */
  188. #include <stdlib.h>
  189. #endif
  190.  
  191. /* EXIT_SUCCESS and EXIT_FAILURE should be defined in <stdlib.h>
  192.  * (or above if non-standard); define here if necessary
  193.  */
  194.  
  195. #ifndef EXIT_SUCCESS
  196. #define EXIT_SUCCESS    0
  197. #endif
  198. #ifndef EXIT_FAILURE
  199. #define EXIT_FAILURE    1
  200. #endif
  201.  
  202. /* definition of NULL (if needed) */
  203.  
  204. #ifndef NULL
  205. #define NULL    0
  206. #endif
  207.  
  208. /*
  209.  * Environment variables (global symbol, logical name on VMS):
  210.  */
  211.  
  212. #define PCAL_OPTS    "PCAL_OPTS"    /* command-line flags */
  213. #define PCAL_DIR    "PCAL_DIR"    /* calendar file directory */
  214. #define PATH_ENV_VAR    "PATH"        /* cf. find_executable() (pcalutil.c) */
  215.  
  216. /*
  217.  * Function-like macros:
  218.  */
  219.  
  220. #define FPR        (void)fprintf
  221. #define PRT        (void)printf
  222.  
  223. /*
  224.  * mask to avoid sign extension when promoting char to int (as in the PUTCHAR
  225.  * macro below); some older compilers may sign-extend this mask anyway, in
  226.  * which case you may want to try defining it as ((int) 0377) or even 255 :
  227.  */
  228. #define CHAR_MSK    0377
  229.  
  230. /* write character _c to file _fp; print as octal escape if _fc(_c) is FALSE */
  231. #define PUTCHAR(_fc, _c, _fp) \
  232.     FPR((_fp), (_c) == ' ' || _fc((_c) & CHAR_MSK) ? "%c" : "\\%03o" , (_c) & CHAR_MSK)
  233.  
  234. #define PUTSTR(_fc, _s, _fp) \
  235.     do { char *_p; for (_p = (_s); *_p; *_p++) PUTCHAR(_fc, *_p, _fp); } while (0)
  236.  
  237. #define IS_LEAP(y)    ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
  238. #define LENGTH_OF(m, y) (month_len[(m)-1] + ((m) == FEB && IS_LEAP(y)))
  239. #define YEAR_LEN(y)    (IS_LEAP(y) ? 366 : 365)
  240. #define DAY_OF_YEAR(m, d, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) + d)
  241. #define OFFSET_OF(m, y) ((month_off[(m)-1] + ((m) > FEB && IS_LEAP(y))) % 7)
  242. #define FIRST_OF(m, y)    calc_weekday(m, 1, y)
  243. #define START_BOX(m, y)    ((FIRST_OF(m, y) - first_day_of_week + 7) % 7)
  244.  
  245. #define PREV_MONTH(m, y) ((m) == JAN ? DEC : (m) - 1)
  246. #define PREV_YEAR(m, y)  ((m) == JAN ? (y) - 1 : (y))
  247. #define NEXT_MONTH(m, y) ((m) == DEC ? JAN : (m) + 1)
  248. #define NEXT_YEAR(m, y)  ((m) == DEC ? (y) + 1 : (y))
  249.  
  250. #define INIT_COLORS    if (1) { \
  251.     memcpy(day_color, default_color, sizeof(day_color)); \
  252.     holiday_color = HOLIDAY_COLOR; \
  253.     weekday_color = WEEKDAY_COLOR; \
  254.     } else
  255.  
  256. #define P_LASTCHAR(p)    ((p) && *(p) ? (p) + strlen(p) - 1 : NULL)
  257. #define LASTCHAR(p)    (p)[strlen(p) - 1]
  258.  
  259. #define IS_NUMERIC(p)    ((p)[strspn((p), DIGITS)] == '\0')
  260. #define IS_EURDATE(p)    ((ispunct((p)[strspn((p), DIGITS)])) && \
  261.              ((p)[strspn((p), DIGITS)+1] == '\0'))
  262. #define IS_WILD(w)    ((w) >= WILD_FIRST && (w) <= WILD_LAST)
  263.  
  264. #define MAKE_DATE(dt, m, d, y) \
  265.     if (1) { (dt).mm = m; (dt).dd = d; (dt).yy = y; } else
  266.  
  267. #define ERR(errmsg) \
  268.     FPR(stderr, E_ILL_LINE, progname, errmsg, filename, line);
  269.  
  270. #define DEBUG(f)    ((debug_flags & f) != 0)
  271.  
  272. #ifdef __STDC__
  273. #define TOLOWER(c)    tolower(c)
  274. #else
  275. #define TOLOWER(c)    (isupper(c) ? tolower(c) : (c))
  276. #endif
  277.  
  278. #ifndef isodigit            /* rare */
  279. #define isodigit(c)    ((c) >= '0' && (c) <= '7')
  280. #endif
  281. #ifndef isxdigit            /* ANSI standard */
  282. #define isxdigit(c) \
  283.     (isdigit(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
  284. #endif
  285.  
  286. /* debug subflag codes (must be distinct) - cf. pcallang.h */
  287.  
  288. #define DEBUG_DATES    (1 << 1)
  289. #define DEBUG_MOON    (1 << 2)
  290. #define DEBUG_PATHS    (1 << 3)
  291. #define DEBUG_OPTS    (1 << 4)
  292. #define DEBUG_PP    (1 << 5)
  293. #define DEBUG_TEXT    (1 << 6)
  294.  
  295. /* preprocessor token codes - cf. get_token(), pcallang.h */
  296.  
  297. #define PP_DEFINE     0
  298. #define PP_ELIF         1
  299. #define PP_ELSE         2
  300. #define PP_ENDIF     3
  301. #define PP_IFDEF     4
  302. #define PP_IFNDEF     5
  303. #define PP_INCLUDE     6
  304. #define PP_UNDEF     7
  305. #define PP_OTHER    -1    /* not pp token */
  306.  
  307. /* ordinal number codes - cf. get_ordinal(), pcallang.h */
  308.  
  309. #define ORD_NEGNUM    -1    /* negative ordinal (-2nd == next to last) */
  310. #define ORD_POSNUM     1    /* positive ordinal */
  311. #define ORD_ODD         2    /* special codes for "odd" and "even" */
  312. #define ORD_EVEN     3
  313. #define ORD_ALL         4    /* special code for "all" used as ordinal */
  314. #define ORD_OTHER     0    /* not ordinal token */
  315.  
  316. /* ordinal numbers themselves - added for predefined holiday routines */
  317.  
  318. #define FIRST         1
  319. #define SECOND         2
  320. #define THIRD         3
  321. #define FOURTH         4
  322. #define FIFTH         5
  323. #define LAST        -1
  324.  
  325. /* moon phase codes - cf. pcallang.h and moonphas.c; these must take the
  326.  * values 0 (NM) .. 3 (3Q) since they are used in phase calculations
  327.  */
  328.  
  329. #define MOON_NM         0    /* new moon */
  330. #define MOON_1Q         1    /* first quarter */
  331. #define MOON_FM          2    /* full moon */
  332. #define MOON_3Q         3    /* last quarter */
  333. #define MOON_OTHER    -1    /* unrecognizable */
  334.  
  335. /* date type codes - cf. date_type(), get_keywd(), and pcallang.h */
  336.  
  337. #define DT_ALL         0    /* "all" keyword" */
  338. #define DT_NOTE         1    /* "note" keyword */
  339. #define DT_OPT         2    /* "opt" keyword */
  340. #define DT_YEAR         3    /* "year" keyword */
  341. #define DT_MONTH     4    /* name of month */
  342. #define DT_DATE         5    /* date of form dd/mm{/yy} or mm/dd{/yy} */
  343. #define DT_EURDATE     6    /* European date of form dd <month> */
  344. #define DT_ORDINAL     7    /* ordinal (first, 1st, ... last) */
  345. #define DT_WEEKDAY     8    /* weekday name */
  346. #define DT_HOLIDAY     9    /* predefined holiday */
  347. #define DT_OTHER    -1    /* unrecognizable first token */
  348.  
  349. /* preposition token codes - cf. get_prep(), pcallang.h */
  350.  
  351. #define PR_BEFORE     0
  352. #define PR_ON_BEFORE     1
  353. #define PR_AFTER     2
  354. #define PR_ON_AFTER     3
  355. #define PR_NEAREST     4
  356. #define PR_OTHER    -1    /* not a preposition */
  357.  
  358.  
  359. /*
  360.  * Miscellaneous other constants:
  361.  */
  362.  
  363. #define COMMENT_CHAR    '#'    /* delimiter for datefile comments */
  364.  
  365. #define RGB_CHAR    ':'    /* delimiter for red/green/blue values */
  366.  
  367. #ifndef TRUE
  368. #define FALSE        0    /* pseudo-Booleans */
  369. #define TRUE        1
  370. #endif
  371.  
  372. #define MAX_FILE_NESTING 10    /* maximum nesting level for file inclusion */
  373. #define MAX_IF_NESTING    20    /* maximum nesting level for if{n}def */
  374.  
  375. #define MAX_PP_SYMS    100    /* number of definable preprocessor symbols */
  376. #define PP_SYM_UNDEF     -1    /* flag for undefined symbol */
  377.  
  378. #define EXPR_ERR    -1    /* expression parsing error */
  379.  
  380. #define MIN_YR        1753    /* significant years (calendar limits) */
  381. #define MAX_YR        9999
  382.  
  383. #define CENTURY        1900    /* default century for two-digit years */
  384.  
  385. #define SCREENWIDTH    78    /* command-line message in usage() */
  386.  
  387. #define FEB_29_OK     1    /* if != 0, ignore 2/29 of common year */
  388.  
  389. #define KEEP_NULL_LINES     1    /* if != 0, copy blank text lines to output */
  390.  
  391. #define NEAREST_INCR     1    /* if 1, disambiguate "nearest" as later    */
  392.                 /* date; if -1, to earlier (cf. readfile.c) */
  393.  
  394. #define JAN         1    /* months (for predefined holiday routines) */
  395. #define FEB         2
  396. #define MAR         3
  397. #define APR         4
  398. #define MAY         5
  399. #define JUN         6
  400. #define JUL         7
  401. #define AUG         8
  402. #define SEP         9
  403. #define OCT        10
  404. #define NOV        11
  405. #define DEC        12
  406. #define NOT_MONTH    -1    /* not valid month */
  407.  
  408. #define ALL_MONTHS     0    /* select all months */
  409. #define ENTIRE_YEAR    13    /* select entire year as one entity */
  410.  
  411. #define SUN         0    /* weekdays - cf. wildcard codes below */
  412. #define MON         1
  413. #define TUE         2
  414. #define WED         3
  415. #define THU         4
  416. #define FRI         5
  417. #define SAT         6
  418. #define NOT_WEEKDAY    -1    /* not valid weekday */
  419.  
  420. #define NOT_HOLIDAY    -1    /* flag for end of holiday list */
  421.  
  422. /* wildcards - cf. days[] in pcallang.h and pdatefcn[] in pcalglob.h */
  423.  
  424. #define ANY_DAY         7    /* special - matches any day */
  425. #define ANY_WEEKDAY     8    /* matches any weekday (including holidays) */
  426. #define ANY_WORKDAY     9    /* matches any weekday (excluding holidays) */
  427. #define ANY_HOLIDAY    10    /* matches any holiday */
  428. #define ANY_NONWEEKDAY    11    /* converses of above three */
  429. #define ANY_NONWORKDAY    12
  430. #define ANY_NONHOLIDAY    13
  431. /* moon phase wildcards - must be in same order as MOON_* below */
  432. #define ANY_NM        14    /* matches any new moon, etc. */
  433. #define ANY_1Q        15
  434. #define ANY_FM        16
  435. #define ANY_3Q        17
  436.  
  437. #define WILD_FIRST    ANY_DAY
  438. #define WILD_FIRST_WKD    ANY_DAY
  439. #define WILD_LAST_WKD    ANY_NONHOLIDAY
  440. #define WILD_FIRST_MOON ANY_NM 
  441. #define WILD_LAST_MOON    ANY_3Q
  442. #define WILD_LAST    ANY_3Q
  443.  
  444.  
  445. #define DAY_TEXT    0    /* types of text in data structure */
  446. #define HOLIDAY_TEXT    1
  447. #define NOTE_TEXT    2
  448.  
  449. #define NOTE_DEFAULT    -1    /* default note box number (-1 = last box) */
  450. #define FIRST_NOTE_BOX     0    /* first box position for notes text */
  451. #define LAST_NOTE_BOX    41    /* last position (w/o small calendars) */
  452. #define NULL_NOTE_BOX    -1    /* negative number for nonexistent box */
  453.  
  454. /* number and range of dummy days for notes text */
  455. #define NUM_NOTE_DAYS    (LAST_NOTE_BOX - 28 + 1)    
  456. #define FIRST_NOTE_DAY    32
  457. #define LAST_NOTE_DAY    (FIRST_NOTE_DAY + NUM_NOTE_DAYS - 1)
  458.  
  459. #define MAX_DATES    366    /* maximum "wildcard" dates */
  460.  
  461. #define MAXWORD        100    /* maximum words in date file line */
  462. #define STRSIZ        200    /* size of misc. strings */
  463. #define VALSIZ        12    /* size of numeric value strings */
  464. #define LINSIZ        512    /* size of source line buffer */
  465.  
  466. #define MAXARGS        3    /* numeric command-line args */
  467.  
  468. #define WHITESPACE    " \t"    /* token delimiters in date file */
  469. #define DIGITS        "0123456789"
  470.  
  471. /* passes where flags may be recognized (cf. get_args(), pcallang.h) */
  472. #define P_CMD0    (1 << 1)    /* parsed in command line pre-pass (-Z only) */
  473. #define P_ENV    (1 << 2)    /* parsed from environment variable */
  474. #define P_CMD1    (1 << 3)    /* parsed in first command-line pass */
  475. #define P_OPT    (1 << 4)    /* parsed on "opt" lines in date file */
  476. #define P_CMD2    (1 << 5)    /* parsed in second command-line pass */
  477.  
  478. /*
  479.  * Defaults for calendar layout:
  480.  */
  481.  
  482. #ifdef EPS
  483. #define PS_RELEASE    "PS-Adobe-2.0 EPSF"    /* for comments at top */
  484. #else
  485. #define PS_RELEASE    "PS-Adobe-1.0"        /* for comments at top */
  486. #endif
  487.  
  488. /* if MAPFONTS is defined, generate PS code to re-map text fonts (cf.
  489.  * fontmaps.ps) according to either the Roman8 or ISO Latin1 definitions of
  490.  * the 8-bit character set.  Note that the overhead to do this slows
  491.  * PostScript down - especially for small jobs - so users in English-
  492.  * speaking countries might prefer to leave MAPFONTS undefined.
  493.  *
  494.  * Speakers of European languages other than English may select either the
  495.  * Roman8 or ISO Latin1 definitions by defining MAPFONTS as ROMAN8 or LATIN1
  496.  * (respectively) in the Makefile.
  497.  */
  498.  
  499. #define NOMAP    0                /* no mapping */
  500. #define ROMAN8    1                /* map to Roman8 */
  501. #define LATIN1    2                /* map to Latin1 */
  502.  
  503. #define MAPPING_R    "Roman8"
  504. #define MAPPING_L    "Latin1"
  505.  
  506. /* if MAPFONTS is defined in the Makefile, make sure it's correct */
  507. #ifdef MAPFONTS
  508. #if (MAPFONTS != ROMAN8 && MAPFONTS != LATIN1)
  509. #undef MAPFONTS    
  510. #define MAPFONTS    NOMAP
  511. #endif
  512. #else
  513. #define MAPFONTS    NOMAP
  514. #endif
  515.  
  516. /* default font names and sizes (large calendars) */
  517.  
  518. #ifndef TITLEFONT
  519. #define TITLEFONT    "Times-Bold/48"        /* month/year title */
  520. #endif
  521. #ifndef DATEFONT
  522. #define DATEFONT    "Times-Bold/25"        /* dates */
  523. #endif
  524. #ifndef NOTESFONT
  525. #define NOTESFONT    "Helvetica-Narrow/6"    /* notes in boxes */
  526. #endif
  527.  
  528. /* define secondary fonts in terms of main fonts */
  529. #define WEEKDAYFONT    "titlefont"        /* weekday names */
  530. #define FOOTFONT    "titlefont"        /* footer strings */
  531. #define HEADINGFONT    "titlefont"        /* notes box heading */
  532.  
  533. /* define MAP_DATEFONT as 1 if any secondary font (above) is defined as
  534.  * "datefont" (cf. writefil.c); otherwise, define as 0
  535.  */
  536. #define MAP_DATEFONT    0            /* re-map date font? */
  537.  
  538. /* font sizes (small, medium, large calendars respectively) - moved here
  539.  * from pcalinit.ps; enlarged (again) for medium (whole-year) calendars
  540.  */
  541. #define SMALL        0
  542. #define MEDIUM        1
  543. #define LARGE        2
  544. #define CALSIZE        { "small", "medium", "large" };
  545.  
  546. #define TITLEFONTSIZE    { 60, 64, 48 }    /* month/year (cf. TITLEFONT above) */
  547. #define DATEFONTSIZE    { 60, 56, 25 }    /* dates (cf. DATEFONT above) */
  548. #define WEEKDAYFONTSIZE    {  0, 30, 12 }    /* weekdays */
  549. #define FOOTFONTSIZE    {  0, 14, 12 }    /* footer strings */
  550. #define HEADINGFONTSIZE    12        /* same as large weekdays */
  551.  
  552. #define GRIDLINEWIDTH   {2.5,  2,  1 }    /* grid lines */
  553. #define DATEMARGIN    { 10,  8,  4 }  /* top/side date margin */
  554.  
  555. #ifndef SHADING
  556. #define SHADING        "0.8/0.9"    /* default shading (dates/fill boxes) */
  557. #endif
  558.  
  559. #define LFOOT         ""              /* default foot strings */
  560. #define CFOOT         ""
  561. #define RFOOT         ""
  562.  
  563. #define LANDSCAPE      90        /* degrees to rotate */
  564. #define PORTRAIT         0
  565. #define ROTATE           LANDSCAPE    /* default */
  566.  
  567. /* scaling/translation factors based on 8.5 x 11 inch (612 x 792 point) page */
  568.  
  569. #define XSVAL_L        "1"        /* scale/translate values (landscape) */
  570. #define YSVAL_L        "1"
  571. #define XTVAL_L        "46"        /* (792 - 700) / 2 = 46 */
  572. #define YTVAL_L        "-120"
  573. #define XSVAL_P        "0.773"        /* scale/translate values (portrait) */
  574. #define YSVAL_P        "0.773"        /* 612/792 */
  575. #define XTVAL_P        "46"
  576. #define YTVAL_P        "492"        /* 612 - 120 = 492 */
  577.  
  578. #define    NCOPY        "1"        /* copies of each output page */
  579. #define MAXCOPY        100        /* just in case... */
  580.  
  581. #if (ROTATE == LANDSCAPE)        /* select appropriate defaults */
  582. #define XSVAL        XSVAL_L
  583. #define YSVAL        YSVAL_L
  584. #define XTVAL        XTVAL_L
  585. #define YTVAL        YTVAL_L
  586. #else
  587. #define XSVAL        XSVAL_P
  588. #define YSVAL        YSVAL_P
  589. #define XTVAL        XTVAL_P
  590. #define YTVAL        YTVAL_P
  591. #endif
  592.  
  593. #define USA_DATES    0        /* date styles */
  594. #define EUR_DATES    1
  595. #ifndef DATE_STYLE
  596. #define DATE_STYLE    USA_DATES    /* default */
  597. #endif
  598.  
  599. #ifndef FIRST_DAY
  600. #define FIRST_DAY    SUN        /* first day of logical week */
  601. #endif
  602.  
  603. /* values below must be in sync with color_names[] in pcallang.h and also
  604.  * with prtday{} in pcalinit.ps
  605.  */
  606. #define BLACK        0        /* colors for dates */
  607. #define GRAY        1
  608. #define OUTLINE        2
  609. #define OUTLINE_GRAY    3
  610. #define NUM_COLORS    4        /* total number of colors */
  611.  
  612. #define HOLIDAY_DEFAULT    -1        /* use same color as weekends */
  613. #define    HOLIDAY_COLOR    HOLIDAY_DEFAULT
  614.  
  615. /* default time zone for -z flag; you may optionally define this as
  616.  * (say) "5 [Boston]" (note space) to print the city in the -h message
  617.  */ 
  618. #ifndef TIMEZONE
  619. #define TIMEZONE    "0"        /* hours west of GMT/UTC */
  620. #endif
  621.  
  622. /* default colors for weekdays (presumes black and at most one other color -
  623.  * cf. color_msg() in pcal.c)
  624.  */
  625. #define DAY_COLOR    { GRAY, BLACK, BLACK, BLACK, BLACK, BLACK, GRAY }
  626. #define WEEKDAY_COLOR    BLACK        /* prevalent color in DAY_COLOR */
  627.  
  628. #define NO_DATEFILE     0        /* date file (if any) to use */
  629. #define USER_DATEFILE    1
  630. #define SYS_DATEFILE    2
  631.  
  632. /* position of small calendars */
  633. #define SC_NONE        0        /* suppress small calendars */
  634. #define SC_LAST        1        /* use last two boxes */
  635. #define SC_FIRST    2        /* use first two boxes */
  636. #define SC_SPLIT    3        /* split between first and last */
  637. #define SMALL_CAL_POS    SC_LAST        /* default */
  638.  
  639. /* box numbers for small calendars - must conform to order defined above */
  640. #define PREV_CAL_BOX    \
  641.     { NULL_NOTE_BOX, LAST_NOTE_BOX - 1, FIRST_NOTE_BOX, FIRST_NOTE_BOX }
  642. #define NEXT_CAL_BOX    \
  643.     { NULL_NOTE_BOX, LAST_NOTE_BOX, FIRST_NOTE_BOX + 1, LAST_NOTE_BOX }
  644.  
  645. /* values below must be in sync with cond[] in writefil.c */
  646. #define NO_MOONS    0        /* no moon icons */
  647. #define ALL_MOONS    1        /* moon icon on every day */
  648. #define SOME_MOONS    2        /* icons on full, half, new moons */
  649. #define DRAW_MOONS    NO_MOONS    /* default */
  650.  
  651. #define NO_JULIANS    0        /* no Julian dates */
  652. #define ALL_JULIANS    1        /* Julian date + days left */
  653. #define SOME_JULIANS    2        /* just Julian dates */
  654. #define JULIAN_DATES    NO_JULIANS    /* default: none */
  655.  
  656. #define DO_WHOLE_YEAR    FALSE        /* -w default */
  657. #define CALENDAR_OUT    FALSE        /* -c default */
  658. #define BLANK_BOXES    FALSE        /* -B default */
  659.  
  660. /*
  661.  * Global typedef declarations for data structure (cf. readfile.c)
  662.  */
  663.  
  664. /*
  665.  * The internal data structure consists of a series of linked lists as 
  666.  * pictured below (for clarity, only one instance of each node is shown):
  667.  *
  668.  *
  669.  * head
  670.  *  |
  671.  *  |        year_info
  672.  *  |    -----------------           month_info
  673.  *   -->| year            |       -----------------            day_info
  674.  *      | month_info*[0]  |----->| holidays        |       ----------------
  675.  *      |   ...           |      | day_info*[0]    |----->| is_holiday     |
  676.  *      | month_info*[11] |--->  |   ...           |      | text_string*   |--->
  677.  *      | next year_info* |--    | day_info*[30]   |--->  | next day_info* |-- 
  678.  *       -----------------   |   | day_info*[NOTE] |--->   ----------------   |
  679.  *                           |   |   ...           |                          |
  680.  *                           |    -----------------                           |
  681.  *             ...        <--                                     ...      <--
  682.  *
  683.  * 
  684.  * Each year_info node consists of the year, 12 pointers (Jan .. Dec) to
  685.  * month_info nodes, and a pointer to the next year_info node in the chain.
  686.  * (The year_info chain is maintained in ascending order by year.)
  687.  *
  688.  * Each month_info node consists of a bitmap of the holidays for that month, 
  689.  * a pointer to the day_info chain for all 31 possible days of the month, and
  690.  * N additional pointers to the day_info chains for the "Notes" pseudo-days. 
  691.  * (A day_info chain is a linked list of all the text entries for a given
  692.  * day, in the order in which they were encountered in the date file.)
  693.  *
  694.  * Each day_info node consists of a flag indicating whether the associated
  695.  * text string is holiday or non-holiday text (any given day may have both),
  696.  * a pointer to the text string itself, and a pointer to the next day_info 
  697.  * node in the chain.
  698.  *
  699.  */
  700.  
  701. typedef struct d_i {
  702.     int is_holiday;
  703.     char *text;
  704.     struct d_i *next;
  705.     } day_info;
  706.  
  707. typedef struct m_i {
  708.     unsigned long holidays;
  709.     day_info *day[LAST_NOTE_DAY];    /* including extra days for notes */
  710.     } month_info;
  711.  
  712. typedef struct y_i {
  713.     int year;
  714.     month_info *month[12];
  715.     struct y_i *next;
  716.     } year_info;
  717.  
  718. /*
  719.  * Global typedef declaration for date structure (cf. parse_ord())
  720.  */
  721.  
  722. typedef struct {
  723.     int mm;
  724.     int dd;
  725.     int yy;
  726. } DATE;
  727.  
  728. /*
  729.  * Global typedef declarations for keyword descriptors (cf. pcallang.h)
  730.  */
  731.  
  732. typedef struct {
  733.     char *name;
  734.     int   code;
  735.     } KWD;
  736.  
  737. typedef struct {
  738.     char *name;
  739.     int   code;
  740.     int   value;
  741.     } KWD_O;        /* keyword plus ordinal value */
  742.  
  743. typedef struct {
  744.     char *name;
  745.     int   code;
  746. #ifdef PROTOS
  747.     int (*pfcn)(char *);
  748. #else
  749.     int (*pfcn)();
  750. #endif
  751.     } KWD_F;        /* keyword plus dispatch function */
  752.  
  753. typedef struct {
  754.     char *name;
  755.     char *def;        /* "def" and "pfcn" are mutually exclusive */
  756. #ifdef PROTOS
  757.     int (*pfcn)(DATE *);
  758. #else
  759.     int (*pfcn)();
  760. #endif
  761.     } KWD_H;        /* keyword, equivalent string, dispatch fcn */
  762.  
  763. /* 
  764.  * Global typedef declaration for flag usage struct (cf. pcallang.h, get_args())
  765.  */
  766.  
  767. typedef struct {
  768.     char flag;        /* name of flag */
  769.     char has_arg;        /* TRUE if flag takes (optional) arg */
  770.     char passes;        /* "or" of P_xxx for relevant passes */
  771.     } FLAG_USAGE;
  772.  
  773. /*
  774.  * Global typedef declaration for debugging info struct (cf. pcallang.h)
  775.  */
  776.  
  777. typedef struct {
  778.     char flag;        /* name of flag */
  779.     int  value;        /* value corresponding to flag (1 << n) */
  780.     } DEBUG_INFO;
  781.  
  782. /*
  783.  * Global typedef declarations for usage message (cf. pcallang.h, usage())
  784.  */
  785.  
  786. typedef struct {
  787.     char flag;        /* name of flag */
  788.     char *meta;        /* metaname for argument (if any) */
  789.     char *text;        /* associated text */
  790.     char *def;        /* default value (if any) */
  791.     } FLAG_MSG;
  792.  
  793. typedef struct {
  794.     char *desc;        /* description of param */
  795.     char *text;        /* associated text */
  796.     } PARAM_MSG;
  797.  
  798. typedef char *DATE_MSG;        /* date file syntax message */
  799.  
  800.